package Ticketing.test01;

/**
 * @Author czl
 * @Date 2024-03-20
 */
public class Cinema extends Thread{
    private static int piao = 50 ;

    private String lock = "lock";

    @Override
    public void run() {
        if (piao>=0){
            while (piao>=1){
                synchronized (lock){
                    System.out.println(Thread.currentThread().getName()+"出售了第" + piao + "张票");
                    piao--;
                }
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
